package cn.biplam.back.operator.mdManage;

import java.util.ArrayList;

import cn.biplam.common.client.DataFilter;
import cn.biplam.common.client.OperatorResult;
import cn.biplam.common.interfaces.DataOperator;
import cn.biplam.common.tools.TOOLS;
import cn.biplam.common.wrapper.ErrorMessage;

/**
 * 	业务模型表类型表数据访问类
 * @author XiaoRuxing 2009-5-16下午03:37:47
 * @version 1.0
 */
public class OptModelType extends DataOperator{

	private static final String tName="model_type";

	public OptModelType()
	throws ErrorMessage {
		super(tName);
	}

	@Override
	protected OperatorResult _exchange() throws ErrorMessage {
		ArrayList<String> sql=new ArrayList<String>();
		switch(TOOLS.stringToInt(opId)){
		case 21090301:
			this.getModelTypeById(sql, filter);
			return this.doing(sql,Operator_Type.Select);
		case 21090302:
			this.getAllModelType(sql, filter);
			return this.doing(sql,Operator_Type.Select);	
		default:
			throw new ErrorMessage("Data Operator id not found:"+ opId+" !");
		}
	}

	/**
	 * 根据业务模型类型ID查询业务模型类型
	 */
	public void getModelTypeById(ArrayList<String> sql,DataFilter filter){
		StringBuilder sp=new StringBuilder();
		sp.append("select * from model_type  ");
		sp.append("where model_type_id='"+filter.getValue("model_type_id")+"' ");
		sql.add(sp.toString());
	}

	/**
	 * 查询所有业务模型类型
	 */
	public void getAllModelType(ArrayList<String> sql,DataFilter filter){
		StringBuilder sp=new StringBuilder();
		sp.append("select * from model_type  order by model_type_id");
		sql.add(sp.toString());
	}
}
